package com.chujian.Adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.chujian.model.NotificationBean;
import com.chujian.orderingsystem.R;

public class NotificationListAdapter extends BaseAdapter{
	private List<NotificationBean>mDataList;
	private LayoutInflater mLayoutInflater;
	private Context context;
	
	public NotificationListAdapter(List<NotificationBean> mDataList, Context context) {
		super();
		this.mDataList = mDataList;
		this.context = context;
		mLayoutInflater=LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mDataList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mDataList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder=null;
		if(convertView==null){
			holder=new ViewHolder();
			convertView=mLayoutInflater.inflate(R.layout.notification_list_item, null);
			holder.item=(TextView) convertView.findViewById(R.id.tv_notification_list_item);
			holder.subItem=(TextView) convertView.findViewById(R.id.tv_notification_list_item_sub);
			convertView.setTag(holder);
		}else{
			holder=(ViewHolder) convertView.getTag();
		}
		
		holder.item.setText(mDataList.get(position).getAlert());
		holder.subItem.setText(mDataList.get(position).getMsgContent());
		
		
		return convertView;
	}
	class ViewHolder{
		public TextView item;
		public TextView subItem;
	}
}
